/*
 * @Author: Penk
 * @LastEditors: Penk
 * @LastEditTime: 2022-10-28 17:24:20
 * @FilePath: \autojs教程\04-自动刷视频_初版.js
 */
require("打印控制台.js");

// 打开app
launchApp("抖音极速版");

// 休眠5000毫秒
sleep(5000);


// 全局变量-脚本
var myApp = {};

// 运行操作的概率
var onoff = {
  zanPercent: 100,
  commentPercent: 0,
  starPercent: 0,
  transmitPercent: 0,
}

// 点赞
myApp.zan = function () {
  console.log("正在进行点赞...");
  var btn_s = descContains("未点赞").clickable().find();
}
// 评论
myApp.comment = function () {
  console.log("正在进行评论...");
}
// 收藏
myApp.star = function () {
  console.log("正在进行收藏...");
}
// 转发
myApp.transmit = function () {
  console.log("正在进行转发...");
}

// 自动化
myApp.auto = function () {
  if (random(1, 100) <= onoff.zanPercent) {
    this.zan();
    sleep(2000);
  }
  if (random(1, 100) <= onoff.commentPercent) {
    this.comment();
    sleep(2000);
  }
  if (random(1, 100) <= onoff.starPercent) {
    this.star();
    sleep(2000);
  }
  if (random(1, 100) <= onoff.transmitPercent) {
    this.transmit();
    sleep(2000);
  }
}

var i = 1;
// 循环操作
while (true) {
  // 模板字符串
  console.log(`正在浏览第${i++}条视频`);
  // 浏览5秒钟视频
  sleep(5000);
  // 自动刷视频
  myApp.auto();
  // 浏览2秒钟视频
  sleep(2000);
  // 滑动到下一条视频
  gesture(500, [430, 1600], [500, 600]);
}